<!--#include file="Ini.asp"-->
<!--#include file="../AspLib/Functions.asp"-->

<%
Response.expires = 0
MREGIAO=REQUEST("REGIAO")
MDIVUL=REQUEST("DIVUL")
MREF=""
MSQL="SELECT EDITORA,CODOBJETO,TITULO,SERIE,SUM(QTD) AS QTD,SUM(VALOR) AS VALOR FROM PNLD_2005_EDITORA_LIVRO " &_
       " WHERE DIVULGADOR='" & MDIVUL & "'" &_
       " GROUP BY EDITORA,TITULO,CODOBJETO,SERIE ORDER BY VALOR DESC"
Set Conn = Server.CreateObject("ADODB.Connection")
conn.CommandTimeout = 1500
Conn.Open sCo1, sCo2, sCo3
Set rs = Conn.Execute(MSql)			 



%>
<html>
<head>
<title><% = sTitle %></title>
<% = sBODY %>
<% = sCABECALHO %>VENDAS PNLD 2005<% = sFONT %></b>
<table width='100%' border='1'<% =  sTABLE %>>
<tr bgcolor='<% = COR_TARJA %>'>
  <td>Editora</td>
  <td>Livro</td>
  <td>S</td>
  <td>Qtd</td>
  </tr><%
  mcnt=0
  GQTD=0
  GVAL=0
  m100=0
 Do while not rs.eof
    mcnt=mcnt+1
    GQTD=GQTD+rs("qtd")
    if mcnt<101 then
    %><tr>
    <td><% = mid(rs("EDITORA"),1,8) %></td>
    <td><a href="pnld2005_escolas_livros.asp?REGIAO=<% = MREGIAO %>&DIVUL=<% =MDIVUL %>&LIVRO=<% = RS("CODOBJETO") %>&TITULO=<% = rs("TITULO") %>"><% = mid(rs("TITULO"),1,24) %></a></td>
    <td><% = rs("SERIE") %></td>
    <td align='right'><% = FORMATNUMBER(rs("QTD"),0) %></td>
    </tr><%
    else
     m100=m100+rs("qtd")
    end if
    rs.MoveNext     	
  loop

  %><tr>
  <td colspan='3'><b>Restante dos livros=>></td>
  <td align='right'><b><% = FORMATNUMBER(m100,0)  %></td>
  </tr>

  <tr>
  <td colspan='3'><b>&nbsp;Geral</td>
  <td align='right'><b><% = FORMATNUMBER(GQTD,0)  %></td>
  </tr><%


rs.Close : Set rs = Nothing
Conn.Close : Set conn = Nothing 

%>
